package com.system.service.task;

import java.io.File;
import java.text.Format;
import java.text.SimpleDateFormat;

/**
 * Created by lenovo on 2016/3/22.
 */
public class SerachFile {



   public static  void  main(String args[]){

       String filePath="G:/usr/app/bishe/web/";
       try {
           allFile(filePath);
       } catch (Exception e) {
           e.printStackTrace();
       }
   }


    public static void allFile(String FilePath) throws Exception {

        File root = new File(FilePath); //当放在项目路径下时通过request得到项目路径
        showAllFiles(root);

    }

   public final static void showAllFiles(File dir) throws Exception{
        File[] fs = dir.listFiles();
        for(int i=0; i<fs.length; i++){
            System.out.print(fs[i].getAbsolutePath()+"     ");
            long lasttime=fs[i].lastModified();
            Format simpleFormat=new SimpleDateFormat("E dd MMM yyyy hh:mm:ss a");
            String dateString = simpleFormat.format(lasttime);
            System.out.println(dateString+"文件大小"+fs[i].length());
            if(fs[i].isDirectory()&& !fs[i].getName().equals("WEB-INF")){
                try{
                    showAllFiles(fs[i]);
                }catch(Exception e){}
            }
        }
    }


}
